package com.zhuhai.entity;

import com.fasterxml.jackson.annotation.JsonIgnore;
import org.hibernate.annotations.Cascade;
import org.hibernate.annotations.CascadeType;

import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import java.io.Serializable;
import java.util.Date;
import java.util.List;
/**
 * @author zhuhai
 */
@Entity
@Table(name = "t_passenger")
public class Passenger implements Serializable {

    /**
     * 默认的序列化 id.
     */
    private static final long serialVersionUID = 1L;

    /**
     * 成人.
     */
    public static final String TYPE_ADULT = "ADULT";

    /**
     * 儿童.
     */
    public static final String TYPE_CHD = "CHD";

    /**
     * 婴儿.
     */
    public static final String TYPE_INF = "INF";


    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private Integer id;

    private String name;

    private String type;

    private String cardNum;

    private String birthdate;

    private String sex;

    private String cardExpiryDate;

    private String nationality;

    private String cardIssueCountry;

    @Temporal(TemporalType.TIMESTAMP)
    private Date createTime;

    @Temporal(TemporalType.TIMESTAMP)
    private Date updateTime;

    @ManyToOne
    @JoinColumn(name="pnr_id")
    @JsonIgnore
    private Pnr pnr;

    @OneToMany(mappedBy="passenger", fetch=FetchType.LAZY)
    @Cascade(CascadeType.REMOVE)
    private List<TicketInfo> ticketInfo;

    public List<TicketInfo> getTicketInfo() {
        return ticketInfo;
    }

    public void setTicketInfo(List<TicketInfo> ticketInfo) {
        this.ticketInfo = ticketInfo;
    }

    public Pnr getPnr() {
        return pnr;
    }

    public void setPnr(Pnr pnr) {
        this.pnr = pnr;
    }

    public static String getTypeAdult() {
        return TYPE_ADULT;
    }

    public static String getTypeChd() {
        return TYPE_CHD;
    }

    public static String getTypeInf() {
        return TYPE_INF;
    }

    public Integer getId() {
        return id;
    }

    public void setId(final Integer id) {
        this.id = id;
    }

    public String getName() {
        return name;
    }

    public void setName(final String name) {
        this.name = name;
    }

    public String getType() {
        return type;
    }

    public void setType(final String type) {
        this.type = type;
    }

    public String getCardNum() {
        return cardNum;
    }

    public void setCardNum(final String cardNum) {
        this.cardNum = cardNum;
    }

    public String getBirthdate() {
        return birthdate;
    }

    public void setBirthdate(final String birthdate) {
        this.birthdate = birthdate;
    }

    public String getSex() {
        return sex;
    }

    public void setSex(final String sex) {
        this.sex = sex;
    }

    public String getCardExpiryDate() {
        return cardExpiryDate;
    }

    public void setCardExpiryDate(final String cardExpiryDate) {
        this.cardExpiryDate = cardExpiryDate;
    }

    public String getNationality() {
        return nationality;
    }

    public void setNationality(final String nationality) {
        this.nationality = nationality;
    }

    public String getCardIssueCountry() {
        return cardIssueCountry;
    }

    public void setCardIssueCountry(final String cardIssueCountry) {
        this.cardIssueCountry = cardIssueCountry;
    }

    public Date getCreateTime() {
        return createTime;
    }

    public void setCreateTime(final Date createTime) {
        this.createTime = createTime;
    }

    public Date getUpdateTime() {
        return updateTime;
    }

    public void setUpdateTime(final Date updateTime) {
        this.updateTime = updateTime;
    }
}
